<%--
  Created by IntelliJ IDEA.
  User: Root404
  Date: 2023/10/20
  Time: 13:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <input type="text" id="title" name="title"><span style="color: red"></span>
    <input type="text" name="id" id="id1">
    <input type="text" name="id2" id="id2">
    <span id="sp1"></span>
    <span id="sp2"></span>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js">
    </script>
<script>
        $("#title").blur(function () {
            var title=$(this).val();
            $.getJSON("${pageContext.request.contextPath}/register?title="+title,
            function (data) {
                   if(data=="y"){
                       $("span").html("对不起，已经被注册了");
                   }  else {
                       $("span").html("恭喜可以注册了");
                   }
            });
        });

        $("#id1").blur(function () {
            var id=$(this).val();
            $.getJSON("${pageContext.request.contextPath}/findEntryAjaxById?id="+id,
                function (data) {
                        $("#sp1").html(data.title);
                        $("#sp2").html(data.createdate);

                });
        });
</script>
</body>
</html>
